#include<bits/stdc++.h>
#define int long long
#define il inline
#define ct const
#define dl double
#define pk push_back
#define fi first
#define se second
#define pii pair<int,int>
#define mod 998244353
#define N 2010
using namespace std;
il int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);ch=getchar();
	}
	return x*f;
}
char f__[40];
il void write(int x){
	int cnt=0;
	if(x<0){
		putchar('-');x=-x;
	}
	if(!x) putchar('0');
	while(x){
		f__[cnt++]=x%10+'0';x/=10;
	}
	while(cnt) putchar(f__[--cnt]);
}
int n,m,Q,sum1[N][N],sum2[N][N],sum3[N][N];
bool a[N][N];
char S[N];
signed main(){
	freopen("unicom.in","r",stdin);
	freopen("unicom.out","w",stdout);
	n=read();m=read();Q=read();
    for(int i=1;i<=n;++i){
        scanf(" %s",S+1);
        for(int j=1;j<=m;++j) a[i][j]=S[j]-'0';
    }
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j)	sum1[i][j]=sum1[i-1][j]+sum1[i][j-1]-sum1[i-1][j-1]+a[i][j];
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) sum2[i][j]=sum2[i-1][j]+sum2[i][j-1]-sum2[i-1][j-1]+(a[i][j]&&a[i][j-1]);
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) sum3[i][j]=sum3[i-1][j]+sum3[i][j-1]-sum3[i-1][j-1]+(a[i][j]&&a[i-1][j]);
	// cerr<<sum2[]
	while(Q--){
		int lx=read(),ly=read(),rx=read(),ry=read();
		// cerr<<
		write(sum1[rx][ry]-sum1[rx][ly-1]-sum1[lx-1][ry]+sum1[lx-1][ly-1]-(sum2[rx][ry]-sum2[rx][ly]-sum2[lx-1][ry]+sum2[lx-1][ly])-(sum3[rx][ry]-sum3[rx][ly-1]-sum3[lx][ry]+sum3[lx][ly-1]));putchar('\n');
	}
	return 0;
}